﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.SystemConfig.Services;
using Microsoft.Practices.Unity;
using System.Configuration;
using System.Web.Script.Serialization;

namespace Web
{
    public partial class Content : PageBase
    {
        public int usermsgcount = 0;
        public int usermailcount = 0;
        public int usertodocount = 0;

        //[Dependency]
        //public IInstantMessage Instant
        //{
        //    get;
        //    set;
        //}

        [Dependency]
        public IAuth_User SystemConfigComponent
        {
            get;
            set;
        }

        public static int OnlineUserCount = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //GetUserTodoInfo();
                //usermailcount = GetUserMailCount();
                SetMenuVisible();
            }
            currentuseid.Value = CurrentUser.User_ID;
            currentpasswd.Value = CurrentUser.Login_Pwd;
        }

        void SetMenuVisible()
        {
            try
            {
                if (!CheckMenuRight(this.aArchiveSearch.Attributes["href"].ToString()))
                {
                    this.lArchiveSearch.Visible = false;
                }
                if (!CheckMenuRight(this.aSingleWell.Attributes["href"].ToString()))
                {
                    this.lSingleWell.Visible = false;
                }
            }
            catch
            {
            }
        }

        /// <summary>
        /// 获取用户工作信息（即时消息，代办）
        /// </summary>
        private void GetUserTodoInfo()
        {
            //string userId = this.CurrentUser.User_ID;
            //usermsgcount = Instant.GetInstantMessage(userId).Tables[0].Rows.Count;
            //CommissionService comission = new CommissionService();
            //string errmsg = "";
            //CommissionData[] commissonData = comission.GetCommissionData(out errmsg);
            //if (commissonData != null)
            //{
            //    usertodocount = commissonData.Length;
            //}
            //else
            //{
            //    usermsgcount = 0;
            //}
        }


        private int GetUserMailCount()
        {
            //    try
            //    {
            //        string userName = this.CurrentUser.Login_ID;
            //        string userPwd = this.CurrentUser.Login_Pwd;
            //        string adImitationLs = ConfigurationManager.AppSettings["SSoLogion"];
            //        string AppId = ConfigurationManager.AppSettings["EmailAppId"];
            //        POP pop = new POP("mail.cnpc.com.cn", userName, userPwd);
            //        int emailCount = pop.GetNewMailCount();
            //        return emailCount;
            //    }
            //    catch
            //    {
            //        return 0;
            //    }
            //}
            return 0;
        }
    }
}
